local function main(userOb, msgData)
    if not msgData.id then
        return
    end

    local configs = IMPORT_D:query("item")
    if not configs then
        local result = {}
        result.code = 400
        userOb:send_packet("MSGS2CGainBox", result)
        return
    end

    local config = configs[msgData.id]
    if not config then
        local result = {}
        result.code = 401
        userOb:send_packet("MSGS2CGainBox", result)
        return
    end

    if config.type ~= "box" then
        local result = {}
        result.code = 402
        userOb:send_packet("MSGS2CGainBox", result)
        return
    end

    ---!每日宝箱掉落次数限制
    local chestDropNum = IMPORT_D:query("common").chestDropNum

    ---!获取宝箱掉落次数
    local box_number = userOb:query("box_number", config.id) or 0
    if box_number >= chestDropNum then
        local result = {}
        result.code = 404
        userOb:send_packet("MSGS2CGainBox", result)
        return
    end

    ---! 获得宝箱对象
    local box = userOb:add_prop(config.id, true)
    if not box then
        local result = {}
        result.code = 403
        userOb:send_packet("MSGS2CGainBox", result)
        return
    end

    ---! 记录掉落次数
    local number = userOb:today_box_add(config.id)

    ---! 记录宝箱等级
    box.level = userOb:get_level()

    local result = {}
    result.code = 200
    result.id = config.id
    result.number = number
    userOb:send_packet("MSGS2CGainBox", result)
    ITEM_D:send_props_info(userOb)
end

--注册方法
COMMAND_D:register_command("MSGC2SGainBox",GameCmdType.NONE, main)
